using System;
namespace ServiceStack
{
	[AttributeUsage]
	public class ApiAllowableValuesAttribute : AttributeBase
	{
		public string Name
		{
			get;
			set;
		}
		public string Type
		{
			get;
			set;
		}
		public int? Min
		{
			get;
			set;
		}
		public int? Max
		{
			get;
			set;
		}
		public string[] Values
		{
			get;
			set;
		}
		public ApiAllowableValuesAttribute(string name)
		{
			this.Name = name;
		}
		public ApiAllowableValuesAttribute(string name, int min, int max) : this(name)
		{
			this.Type = "RANGE";
			this.Min = new int?(min);
			this.Max = new int?(max);
		}
		public ApiAllowableValuesAttribute(string name, params string[] values) : this(name)
		{
			this.Type = "LIST";
			this.Values = values;
		}
		public ApiAllowableValuesAttribute(string name, Type enumType) : this(name)
		{
			if (enumType.get_IsEnum())
			{
				this.Type = "LIST";
				this.Values = Enum.GetNames(enumType);
			}
		}
		public ApiAllowableValuesAttribute(string name, Func<string[]> listAction) : this(name)
		{
			if (listAction != null)
			{
				this.Type = "LIST";
				this.Values = listAction.Invoke();
			}
		}
	}
}
